package com.flower.auth.controller;

import com.flower.auth.common.entity.Result;
import com.flower.auth.convert.AuthPermissionDTOConverter;
import com.flower.auth.convert.AuthUserDTOConverter;
import com.flower.auth.dto.AuthPermissionDTO;
import com.flower.auth.dto.AuthUserDTO;
import com.flower.domain.convert.AuthPermissionBOConverter;
import com.flower.domain.entity.AuthPermissionBO;
import com.flower.domain.entity.AuthUserBO;
import com.flower.domain.service.AuthPermissionDomainService;
import com.flower.domain.service.AuthUserDomainService;
import com.google.common.base.Preconditions;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author lavender
 * @version 1.0
 * @date 2024-07-16 18:44
 */
@RestController
@RequestMapping("/permission/")
@Slf4j
public class PermissionController {


    @Resource
    private AuthPermissionDomainService authPermissionDomainService;

    @RequestMapping("add")
    public Result<Boolean> register(@RequestBody AuthPermissionDTO authPermissionDTO){

        AuthPermissionBO authPermissionBO = AuthPermissionDTOConverter.INSTANCE.convertDTOToBO(authPermissionDTO);


        Boolean register = authPermissionDomainService.register(authPermissionBO);




        return Result.ok(register);
    }


    @RequestMapping("update")
    public Result<Boolean> update(@RequestBody AuthPermissionDTO authPermissionDTO){


        AuthPermissionBO authPermissionBO = AuthPermissionDTOConverter.INSTANCE.convertDTOToBO(authPermissionDTO);

        authPermissionDomainService.update(authPermissionBO);

        return Result.ok();
    }


    @RequestMapping("delete")
    public Result<Boolean> delete(@RequestBody AuthPermissionDTO authPermissionDTO){


        AuthPermissionBO authPermissionBO = AuthPermissionDTOConverter.INSTANCE.convertDTOToBO(authPermissionDTO);


        Boolean delete = authPermissionDomainService.delete(authPermissionBO);

        return Result.ok(delete);
    }


    @RequestMapping("changeStatus")
    public Result<Boolean> changeStatus(@RequestBody AuthUserDTO authUserDTO){






        return Result.ok();
    }


}
